#ifndef RECVTHREAD_H
#define RECVTHREAD_H

#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QTimer>

//! [0]
class RecvThread : public QThread
{
    Q_OBJECT

public:
    RecvThread(QObject *parent = 0);
    ~RecvThread();

    void startRecv(QSerialPort *port, int waitTimeout);
    void run();

signals:
    void error(const QString &s);
    void timeout(const QString &s);
    void recvOk(const QString &s);

private slots:
    void timer_Handle();

private:
    QSerialPort *port;
    QString response;
    int waitTimeout;
    QMutex mutex;
    bool quit;

    unsigned int serial_cnt;
    QTimer *mTimer;
};
//! [0]

#endif // RECVTHREAD_H

